package com.oamicnet;

import com.oamicnet.entity.Student;
import com.oamicnet.service.StudentService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * Hello world!
 *
 */
@ComponentScan("com.oamicnet")
public class App 
{
    public static void main( String[] args )
    {
        //1-需要加载xml文件
        /*ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        StudentService studentService = context.getBean("studentService",StudentService.class);

        Student student1 = context.getBean("student", Student.class);
        System.out.println(student1);*/


        //2-不需要xml文件
        ApplicationContext context1 =new AnnotationConfigApplicationContext(App.class);
        StudentService studentService = context1.getBean("studentService",StudentService.class);

        Student student1 = context1.getBean("student", Student.class);
        System.out.println(student1);
        studentService.save(student1);
    }
}
